define(function(require, exports, module) {
    "use strict";
    var $ = require("$"),
        app = require("dist/application/app"),
        config = app.config,
        method = app.method;
        $(document).on("click", '[data-toggle="openPost"]', function() {
	      	var  $this=$(this),$form=$this.closest('form'),data=$this.data("set"),type=$this.data("type")||"post",
	      	action=$this.data("action");
	        var is_modal = $form.hasClass("form-modal");
	        var modal = null;
	      	if ($form.length&&$form.valid()) {
	            var  formdata=$form.serializeArray();
	             formdata.push({name:'set',value:data});
	            if (is_modal) {
		            modal = $form.parents(".modal");
		            if (modal) modal.modal('hide');
		            method.OpenWindowWithPost(action||$form.attr("action"),"_blank",formdata,type);
	        	};

	      	};
	    })
})